/**
 * 
 */
package com.thon.dao.user.impl;


import org.springframework.stereotype.Repository;

import com.thon.dao.user.InstitutionDao;
import com.thon.dao.util.AbstractDao;
import com.thon.dao.util.Page;
import com.thon.entity.user.Institution;

/**
 * @file InstitutionDaoImpl.java
 * @author Zemo
 * @mail zemochen@gmail.com
 * @data 2013年10月11日 上午11:32:53
 * @description: TODO
 */
@Repository
public class InstitutionDaoImpl extends AbstractDao<Institution> implements InstitutionDao{
	
	public InstitutionDaoImpl(){
		super(Institution.class);
	}

	@Override
	public Institution getInstitutionByUser(Integer userId) {
		
		String queryString = "FROM Institution WHERE user.id = ? AND status != 0";
		return findOne(queryString, null, userId);
	}

	@Override
	public Page<Institution> findInstutionByStatus(Page<Institution> page,Byte status) {
		
		String queryString;
		if(status==0)
		{	
			queryString = "FROM Institution order by id desc";
		return findPage(page, queryString);
		}
		
		    queryString = "FROM Institution WHERE status = ? order by id desc";
		return findPage(page, queryString, status);
		
		
	}
}
